<?php if( ! defined('BASEPATH')) exit('No direct script access allowed');
/********************
 *@param function:OplusCms 前臺 頁面管理
 *@param datetime 2012-01-05
 *@param author solgh
 ********************/
class Cms extends Lang_Controller { 
  public function __construct(){
    parent::__construct();
    $this->load->model('pages_mdl');
  }

  public function index($unique_url=''){
    if(!empty($unique_url)){
      $this->get_list($unique_url);
      $this->load->view('cms_list_view',$this->data);
    }else{
      show_error('Sorry, the parameter error');
      exit;
    }
  }
  
  //獲取數據
  private function get_list($unique_url){

    $filter_data=array(
      'status'=>1,
      'unique_url'=>$unique_url,
      'language_id'=>$this->data['lang_id'],
    );
    $query=$this->pages_mdl->get_pages_by_unique_url($filter_data);
    if(!empty($query)){
      //更新瀏覽次數
      $this->pages_mdl->add_view_num($query['id']);      
      $this->data['content']=$query['content'];
      $this->data['active']=$unique_url;
      $this->data['title']=$query['title'];
      $this->data['main_image']=$query['main_image'];
      $this->data['list']=$query;
    }else{
      redirect('error_404');
    }
  }
  
  //獲取cms Page
  private function _get_leftmenus($parent=1){
    $this->load->model('pages_mdl'); 
    $data=array('language_id'=>$this->data['lang_id'],'parent'=>$parent,'status'=>1);
    $query=$this->pages_mdl->get_pages($data);
    $this->data['left_menus']=$query;
  }
}